package com.example.demo.listener;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.SpringApplicationRunListener;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;

/**
 * @description:
 * @date: 2019/6/11 22:29.
 * @author: yulipeng.
 */
public class HelloSpringApplicationRunListener
        implements SpringApplicationRunListener {

    public HelloSpringApplicationRunListener(SpringApplication application, String[] args) {
        System.out.println("=======HelloSpringApplicationRunListeners====有参构造器");
    }

    @Override
    public void starting() {

        System.out.println("=ioc容器创建之前===hellospringapplicationrunlisteners.starting()====");
    }

    @Override
    public void environmentPrepared(ConfigurableEnvironment environment) {
        Object o = environment.getSystemEnvironment().get("os.name");
        System.out.println("====HelloSpringApplicationRunListeners.environmentPrepared()===="+o);
    }

    @Override
    public void contextPrepared(ConfigurableApplicationContext context) {
        System.out.println("====HelloSpringApplicationRunListeners.contextPrepared()====");
    }

    @Override
    public void contextLoaded(ConfigurableApplicationContext context) {
        System.out.println("====HelloSpringApplicationRunListeners.contextLoaded()====");
    }

    @Override
    public void finished(ConfigurableApplicationContext context, Throwable exception) {
        System.out.println("====HelloSpringApplicationRunListeners.finished()====");
    }
}
